Skip to content

Conversation

@inaku-Gyan
Copy link
Contributor

Exposed additional optional parameters in the call_tool and connect_to_server methods so that they can fully pass through supported arguments to the underlying session-level methods.

Replace the parameter args in call_tool with arguments so that it's aligned with the original ClientSession.call_tool method.
Use @overload and @deprecated to mark args as deprecated while still supporting its usage.

Motivation and Context

Previously, call_tool and connect_to_server ignored several optional parameters supported by the lower-level ClientSession and session methods.
As a result, certain advanced use cases (e.g., custom timeouts, callbacks, or client metadata) could only be supported by directly accessing lower-level APIs, which was cumbersome and inconsistent.

This change:

  • Adds new parameters to call_tool for timeouts, progress tracking, and metadata.
  • Adds session_params to connect_to_server to configure ClientSession creation directly.
  • Introduces ClientSessionParameters dataclass for clear typing.

How Has This Been Tested?

Pyright static type check and pytest.

Breaking Changes

  • Not strictly breaking, as old usage patterns are still supported.
  • Minor deprecation warning: The args parameter in call_tool is deprecated in favor of arguments.

Types of changes

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

ClientSessionParameters uses dataclasses.dataclass instead of pydantic.BaseModel because BaseModel does not support Protocol-typed fields. Attempts with SkipValidation and arbitrary_types_allowed=True did not resolve the issue.

@maxisbey maxisbey added enhancement New feature or request needs more eyes Needs alignment among maintainers whether this is something we want to add P3 Nice to haves, rare edge cases labels Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request needs more eyes Needs alignment among maintainers whether this is something we want to add P3 Nice to haves, rare edge cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants